#include <iostream>
#include <algorithm>
using namespace std;
int arr[5], freq[500], mxSum_freq[1000];
int main()
{
int mn = 0, mx = 0;
int sum = 0, sum_freq = 0;
for (int i = 0; i < 5; i++)
cin >> arr[i];
sort(arr, arr + 5);
for (int i = 0; i < 5; i++)
sum = sum + arr[i];
mn = arr[0];
for (int i = 1; i < 5; i++)
{
if (arr[i] <= mn)
mn = arr[i];
}
mx = arr[0];
for (int i = 1; i < 5; i++)
{
if (arr[i] >= mx)
mx = arr[i];
}
for (int i = 0; i < 5; i++)
freq[arr[i]]++;
for (int i = mn; i <= mx; i++)
{
if (freq[i] == 2)
mxSum_freq[i] = i * 2;
else if (freq[i] == 3)
mxSum_freq[i] = i * 3;
else if (freq[i] > 3)
mxSum_freq[i] = i * 3;
else if (freq[i] < 2)
mxSum_freq[i] = 0;
}
sum_freq = mxSum_freq[mn];
for (int i = mn + 1; i <= mx; i++)
{
if (mxSum_freq[i] >= sum_freq)
sum_freq = mxSum_freq[i];
}
cout << sum - sum_freq;
return 0;
}
1044. Longest Duplicate Substring | 1032. Stream of Characters |
987. Vertical Order Traversal of a Binary Tree | 952. Largest Component Size by Common Factor |
212. Word Search II | 174. Dungeon Game |
127. Word Ladder | 123. Best Time to Buy and Sell Stock III |
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |
60. Permutation Sequence | 42. Trapping Rain Water |
32. Longest Valid Parentheses | Cutting a material |
Bubble Sort | Number of triangles |
AND path in a binary tree | Factorial equations |
Removal of vertices | Happy segments |
Cyclic shifts | Zoos |
Build a graph | Almost correct bracket sequence |
Count of integers | Differences of the permutations |
Doctor's Secret | Back to School |
I am Easy | Teddy and Tweety |